import { useNoteStore } from "@/state/Stores"; import { GetNoteAPI } from "@/type/wwwAPI"; import { wwwAPI } from "@/utilities/wwwAPI"; import { useQuery } from "@tanstack/react-query"; import { useIntParam, useIsPath, useWant } from "taehui-ts/fe-utilities"; export default function useGetNote() { const { viewUnit } = useNoteStore(); const { param: page } = useIntParam("page", 1); const { param: fit } = useIntParam("fit", 0); const { param: src } = useIntParam("src", 0); const { want } = useWant("/note"); const isPath = useIsPath(); return useQuery({ enabled: isPath("/note"), queryKey: ["note", fit, src, want, page, viewUnit], queryFn: async () => { const { data } = await wwwAPI.get<GetNoteAPI>("/note", { params: { fit, src, want, page, viewUnit, }, }); return data; }, initialData: { totalCount: 0, highestCount: 0, noteCount: 0, notes: [], }, }); }